import json
import os
import openpyxl
import xlwt

workbook = xlwt.Workbook()
#
sheet = workbook.add_sheet('sheet1')

workbook.save('test1.xlsx')
path = '../outcome/'

listFile = os.listdir(path)
cnt = 1
for directory in listFile:
    for subSet in os.listdir(path + '/' + directory):
        print(subSet)
        with open(path + directory + '/' + subSet, 'r') as load_file:
            outcome = json.load(load_file)
            subDataSet = outcome['subDataSet']
            result = outcome['result']
            cntCol = 1

            sheet.write(2, 0, 'precision')
            sheet.write(3, 0, 'recall')
            sheet.write(4, 0, 'pf')
            sheet.write(5, 0, 'f-measure')
            sheet.write(6, 0, 'accuracy')
            sheet.write(7, 0, 'AUC')

            sheet.write(1, cnt, outcome["subDataSet"])
            sheet.write(2, cnt, result[0]['precision:'])
            sheet.write(3, cnt, result[0]['recall:'])
            sheet.write(4, cnt, result[0]['pf:'])
            sheet.write(5, cnt, result[0]['F-measure:'])
            sheet.write(6, cnt, result[0]['accuracy:'])
            sheet.write(7, cnt, result[0]['AUC:'])
            cnt += 1

workbook.save(outcome["method"] + '.xlsx')
